package com.dq.statistics.client.fallBackFactory;

import com.dq.commonutils.vo.Result;
import com.dq.statistics.client.UcenterClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @project: guli_parent
 * @ClassName: UcenterFallBackFactory
 * @author: dq
 * @creat: 2022/9/15 16:59
 */
@Component
@Slf4j
public class UcenterFallBackFactory implements FallbackFactory<UcenterClient> {
    @Override
    public UcenterClient create(Throwable throwable) {
        return new UcenterClient() {
            @Override
            public Result findTotalRegisterCountFromOneDay(String day) {
                Map<String, Integer> resultMap = new HashMap<>();
                resultMap.put("count", 0);
                log.info("Statistics调用Ucenter发送熔断降级",throwable.getMessage());
                return Result.success(resultMap);
            }
        };
    }
}
